<template>
  <div>
    <el-table v-loading="loading" :data="postList">
      <el-table-column label="原有额度(元)" align="center" prop="oldbalance">
        <template slot-scope="scope">
          <span>{{ formatCurrency(scope.row.oldbalance) }}</span>
        </template>
      </el-table-column>
      <el-table-column label="变更额度(元)" align="center" prop="changebalance">
        <template slot-scope="scope">
          <span>{{ formatCurrency(scope.row.changebalance) }}</span>
        </template>
      </el-table-column>
      <el-table-column label="新额度(元)" align="center" prop="newbalance">
        <template slot-scope="scope">
          <span>{{ formatCurrency(scope.row.newbalance) }}</span>
        </template>
      </el-table-column>
      <el-table-column label="状态" align="center" prop="status" :formatter="statusFormat"/>
      <el-table-column label="类型" align="center" prop="jointype" :formatter="typeFormat"/>
      <el-table-column label="备注" align="center" prop="remark"/>
      <el-table-column label="创建时间" align="center" prop="createtime" width="180">
        <template slot-scope="scope">
          <span>{{ dateFormat(scope.row.createtime) }}</span>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />
  </div>
</template>

<script>
  import {assetList, getSendlog} from "@/api/maker/list";

  export default {
    props: {
      row: {
        type: Object,
        require: true
      }
    },
    data() {
      return {
        // 遮罩层
        loading: true,
        // 总条数
        total: 0,
        // 岗位表格数据
        postList: [],
        // 弹出层标题
        title: "",
        // 是否显示弹出层
        open: false,
        // 状态数据字典
        statusOptions: [],
        typeOptions: [],
        // 日期范围
        dateRange: [],
        //统计
        totalData: [],
        // 查询参数
        queryParams: {
          pageNum: 1,
          pageSize: 10,
          joinId: undefined
        },
        content: '',

      };
    },
    created() {
      this.queryParams.userId = this.row.userId;
      this.getList();
      this.statusOptions = [{status: 0, text: '减少'}, {status: 1, text: '增加'}];
      this.typeOptions = [{jointype: 0, text: '默认'}, {jointype: 1, text: '充值'}, {jointype: 2, text: '发券'}];
    },
    methods: {
      getList() {
        this.loading = true;
        assetList(this.queryParams).then(response => {
          this.postList = response.rows;
          this.total = response.total;
          this.loading = false;
        });
      },
      // 岗位状态字典翻译
      statusFormat(row, column) {
        if (null === row.status)
          return '';
        return this.statusOptions[row.status].text;
      },
      typeFormat(row) {
        return this.typeOptions[row.jointype].text;
      },

      // 岗位状态字典翻译
      realnameFormat(row) {
        return row.realName ? row.realName : '-';
      }
    }
  };
</script>
